var util = require("../../../utils/util.js"),
{api} = require("../../../utils/api.js"),
app = getApp();
Page({

    data: {
        czIntegral: [],
        xfIntegral: [],
        statusFlag: 4,
        showEmpty: !1,
        tearoomIndex:0,
        amount:0,
        show:false,
        record:{},
        userInfo:{},
        configInfo:{},
        page:1,
        pageSize:10
    },
    onClickHide(){
        this.setData({show:false})
    },
    showModel(){
        this.setData({show:true})
    },
    onLoad: function(a) {
        this.getUsers()
        this.integralList()
    },
    async getUsers(){
        const data = await app.getUsers();
        data && this.setData(data)
    },
    async integralList(){
        var parmes = {
            page: this.data.page,
            pageSize:this.data.pageSize,
            operate_type:this.data.tearoomIndex
        };
        let {data} = await api.moneyList(parmes);
        let listArr = data && data.list && Array.isArray(data.list.data) ? data.list.data : [];
        let total= data && data.list && data.list.total?data.list.total:0;
        listArr.forEach(item=>{
            item.createtime_text=item.createtime?util.formatTime1(new Date(item.createtime*1000)):''
        })
        this.setData({
            showEmpty: total == 0 ? true : false,
            czIntegral: this.data.page == 1 ? listArr : [...this.data.czIntegral, ...listArr],
            pageScroll: listArr.length < 10 ? false : true
        })
    },
    changeTab(e){
        this.setData({tearoomIndex:e.currentTarget.dataset.flag,page:1});
        this.integralList()
    },
    onShareAppMessage(e) {
        return util.shareEvent(e)
      }
})